package com.weharvest.edu.converter;

import com.weharvest.edu.entity.BackstageUser;
import com.weharvest.edu.view.BackstageUserView;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

public class BackstageUser2OBackstageUserView {
    /**
     * 单独转换
     * @param backstageUser
     * @return
     */
    public static BackstageUserView converter(BackstageUser backstageUser){
        BackstageUserView backstageUserView=new BackstageUserView();
        BeanUtils.copyProperties(backstageUser,backstageUserView);
        return backstageUserView;
    }

    /**
     * 集合转换
     * @param backstageUserList
     * @return
     */
    public static List<BackstageUserView>converter(List<BackstageUser>backstageUserList){
       List<BackstageUserView>backstageUserViewList=
               backstageUserList.stream().map(e -> converter(e)).collect(Collectors.toList());
       return backstageUserViewList;
    }


}
